{include file="common/head"/}
<style>
</style>
<div style="margin: 15px;" class="fadeInUp animated">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>录入新闻栏目</legend>
    </fieldset>
    <form class="layui-form layui-form-pane margin">
        <div class="layui-form-item">
            <label class="layui-form-label">分类:</label>
            <div class="layui-input-inline" >
                <select  name="cate_id" id="cate_id"  class="layui-input" style="font-size: 15px">
                    <option value="1" selected >普通新闻栏目</option>
                    <option value="2" >战区新闻栏目</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">栏目名称：</label>
            <div class="layui-input-2">
                <input type="text" name="cate_name" lay-verify="required" id="cate_name" value="" placeholder="{:lang('pleaseEnter')}栏目名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序：</label>
            <div class="layui-input-2">
                <input type="text" name="sort" id="sort" value="1" lay-verify="required" placeholder="{:lang('pleaseEnter')}排序" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
                <button type="button" class="layui-btn " lay-submit="" lay-filter="add">立即提交</button>
                <a href="{:url('NewsCate/newsCateList')}" class="layui-btn layui-btn-primary">返回</a>
            </div>
        </div>
    </form>
</div>
</body>
{include file="common/foot"/}
<script>
    layui.use(['form','jquery', 'layer'], function () {
        var form = layui.form,layer = layui.layer;$= layui.jquery;

        // 监听常规提交
        form.on('submit(add)', function (data) {
            var loading = layer.load();

            if(data.field.cate_name == "" || data.field.cate_name.length == "0")
            {
                layer.msg("请重新输入栏目名称！",{time:1000,icon:2});
                layer.close(loading);
            }

            if(data.field.sort == "" || data.field.sort == "0")
            {
                layer.msg("请重新输入排序！",{time:1000,icon:2});
                layer.close(loading);
            }

            // 提交到方法 默认为本身
            $.post("{:url('newsCateAdd')}",data.field,function(res){
                layer.close(loading);
                if(res.code == 0){
                    layer.msg(res.msg,{time:1000,icon:1});
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            });
            return false;
        });
    });
</script>
</html>